$(document).ready(function(){
    $(function (){
        $(".state li").click(function () {
            $(this).addClass('active').siblings('li').removeClass('active');
        })
    });
    $(function () {
        $("table tbody").on('click', 'tr', function () {
            $(this).find('s').toggleClass('selected');
        })
    });
    //删除、修改、查询按钮
    $(function () {
        $("table tbody").on('click', 'tr td .detail', function (e) {
            e.stopPropagation();
            console.log('s');
        });
        $("table tbody").on('click', 'tr td .revise', function (e) {
            e.stopPropagation();
            console.log('sfsfds');
        });
        $("table tbody").on('click', 'tr td .delete', function (e) {
            e.stopPropagation();
            $('#mask-box').css('display','block').children('#remove-block').css('display','block');
        });
    });
    $('.delete-more').click(function(){
        $('#mask-box').css('display','block').children('#remove-block').css('display','block');
    })
    $("table thead tr").on('click', 'td s', function () {
        var item=$(this).parent().parent().parent().siblings('tbody').children('tr').find('s');
        if(!$(this).hasClass('selected')){
            $(this).addClass('selected');
            item.addClass('selected');
        }else{
            $(this).removeClass('selected');
            item.removeClass('selected');
        }
    });

});
// 点击取消隐藏删除对话框
$(".cancel").on('click', function (e) {
    e.stopPropagation();
    e.preventDefault();
    $('#mask-box').css('display','none');
});
function deleteActivity(id,that){
	console.log(that);
	var that = $(that).parent("td").parent("tr");
	console.log(that);
	$(".queren").on('click', function (e) {
	    e.stopPropagation();
	    e.preventDefault();
	    $.ajax({
	        url: "deleteActivityById",
	        type: "POST",                       //请求方式
	        data:{id:id},
	        dataType: "json",
	        success: function (result,obj) {
	        	if(result.status){
	        		that.remove();
	        		$('#mask-box').css('display','none');
	        		alertBox(1,"删除成功");
	        	} else{
	        		alertBox(0,"删除失败");
	        	}
	        },
	        fail: function (result) {
	            // 此处放失败后执行的代码
	        }
	    });
	});
}
/**
 * 活动详情
 */
function activityDetail(id){
	window.open("/DistributorSystem/productActivity/activityDetail?id="+id);
}

/**
 * 修改活动
 */
function updateActivity(id){
	window.location.href = "/DistributorSystem/productActivity/updateActivity?id="+id;
}
